package org.hotcommentssys.service.impl;

import org.hotcommentssys.entity.Hotevents;
import org.hotcommentssys.dao.HoteventsDao;
import org.hotcommentssys.service.HoteventsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Hotevents)表服务实现类
 *
 * @author makejava
 * @since 2021-12-04 08:43:40
 */
@Service("hoteventsService")
public class HoteventsServiceImpl implements HoteventsService {
    @Resource
    private HoteventsDao hoteventsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Hotevents queryById(Integer id) {
        return this.hoteventsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Hotevents> queryAllByLimit(int offset, int limit, String keyWord) {
        return this.hoteventsDao.queryAllByLimit(offset, limit, keyWord);
    }

    @Override
    public List<Hotevents> queryAll(Hotevents hotevents) {
        return this.hoteventsDao.queryAll(hotevents);
    }

    /**
     * 新增数据
     *
     * @param hotevents 实例对象
     * @return 实例对象
     */
    @Override
    public Hotevents insert(Hotevents hotevents) {
        this.hoteventsDao.insert(hotevents);
        return hotevents;
    }

    /**
     * 修改数据
     *
     * @param hotevents 实例对象
     * @return 实例对象
     */
    @Override
    public Hotevents update(Hotevents hotevents) {
        this.hoteventsDao.update(hotevents);
        return this.queryById(hotevents.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.hoteventsDao.deleteById(id) > 0;
    }
}
